﻿using Microsoft.UI.Xaml.Data;
using WhaleAccount.Contracts.Services;

namespace WhaleAccount.Helpers;
public class TypeIdToFontIconGlyphConverter : IValueConverter
{
    private readonly ITypeService _typeService;
    public TypeIdToFontIconGlyphConverter()
    {
        _typeService = App.GetService<ITypeService>();
    }
    public object Convert(object value, Type targetType, object parameter, string language)
    {
        var typeId = (int)value;
        var typeList = _typeService.GetTypeListAsync().Result;
        var icon = from t in typeList
                   where t.Id == typeId
                   select t.Icon;
        return icon.First();
    }
    public object ConvertBack(object value, Type targetType, object parameter, string language) => throw new NotImplementedException();
}
